package com.jp.knowledge.http;

import com.jp.knowledge.util.L;
import com.qiniu.android.common.AutoZone;
import com.qiniu.android.common.Zone;
import com.qiniu.android.http.ResponseInfo;
import com.qiniu.android.storage.Configuration;
import com.qiniu.android.storage.UpCompletionHandler;
import com.qiniu.android.storage.UploadManager;

import org.json.JSONObject;

import java.io.File;

/**
 * Created by jiayen on 16/12/1.
 * <p>
 * 上传文件   使用七牛sdk上传
 */

public class UploadUti {
    private static final String TAG = "UploadUti";

    public  static void upload(String path, String token) {
        boolean https = true;
        Zone z1 = new AutoZone(/*https, */null);
        Configuration config = new Configuration.Builder().zone(z1).build();
        UploadManager uploadManager = new UploadManager(config);
        File data = new File(path);
        uploadManager.put(data, null, token, new UpCompletionHandler() {
            @Override
            public void complete(String key, ResponseInfo info, JSONObject response) {
                L.e(TAG, "key=" + key + "======");
                L.e(TAG, "ResponseInfo=====" + info + "======");
                L.e(TAG, "JSONObject=" + response + "======");
            }
        }, null);
    }
}
